package br.com.esporte.negocios.controlador.imp;

import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.stereotype.Service;

import br.com.esporte.negocios.controlador.IMailService;
import br.com.esporte.negocios.entidade.imp.Usuario;

/**
 * 
 * @author Milton Domingues
 *
 */
@Service
public class MailService implements IMailService {

	private JavaMailSenderImpl mailSender;

	public MailService(JavaMailSenderImpl mailSender) {
		this.mailSender = mailSender;
	}

	public JavaMailSenderImpl getMailSender() {
		return this.mailSender;
	}

	@Override
	public void sendMailTemplate() {

	}

	@Override
	public void sendMailText(String texto, Usuario usuario) {
		SimpleMailMessage msg = new SimpleMailMessage();
		msg.setFrom("mtnetoo@gmail.com");
		msg.setTo(usuario.getEmail());
		msg.setSubject("teste");
		msg.setText(texto);
		this.mailSender.send(msg);
	}

	public void setMailSender(JavaMailSenderImpl mailSender) {
		this.mailSender = mailSender;
	}

}
